/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.uhk.ppro.traveler.dao;

import cz.uhk.ppro.traveler.entity.TTrip;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author dusi
 */
public class TripsDao {
    
    private EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu");
    private EntityManager em = emf.createEntityManager();
    
    public TTrip getTrip(int id) {
        return em.find(TTrip.class, Long.parseLong(String.valueOf(id)));
    }
    
    public void removeTrip(TTrip t) {
        em.getTransaction().begin();
        em.remove(t);
        em.getTransaction().commit();
    }
}
